package com.hskn.hss.module.empPlan.vo;

import com.hskn.hss.core.utils.spring.SpringUtils;
import com.hskn.hss.module.depart.entity.SysDepart;
import com.hskn.hss.module.empPlan.entity.EmpPlan;
import com.hskn.hss.module.employeeTrack.entity.EmployeeTrack;
import com.hskn.hss.module.grid.entity.Grid;
import com.hskn.hss.module.grid.vo.GridPlace;
import com.hskn.hss.module.tlemployee.entity.TlEmployee;
import com.hskn.hss.module.user.entity.User;
import com.hskn.hss.module.workgroup.entity.WorkGroup;
import com.hskn.hss.module.workkaoqin.entity.WorkKaoqin;
import com.hskn.hss.utils.LocationUtils;
import com.hskn.hss.utils.StringUtils;
import lombok.Data;
import org.apache.commons.collections.CollectionUtils;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.zone.ZoneRules;
import java.util.List;
import java.util.Objects;
import java.util.function.Function;

@Data
public class ActualOperationListVo implements Serializable {
    /**
     * 计划名称
     */
    private String planName;
    /**
     * 考勤名称
     */
    private String kaoQinName;
    /**
     * 开始时间
     */
    private String startTime;
    /**
     * 结束时间
     */
    private String endTime;
    /**
     * 完成度
     */
    private String degreeCompletion;
    /**
     * 完成度数字
     */
    private BigDecimal degreeCompletionDecimal;
    /**
     * 网格名称
     */
    private String gridName;
    /**
     * 机构名称
     */
    private String depName;
    /**
     * 负责人名称
     */
    private String userName;
    /**
     * 负责人电话
     */
    private String userPhone;
    /**
     * 网格
     */
    private Grid grid;
    /**
     * 人员列表
     */
    private List<EmpActual> empActualList;

    public ActualOperationListVo() {
    }

    public ActualOperationListVo(String planName, String kaoQinName, String startTime, String endTime, String degreeCompletion, String gridName, String depName, String userName, String userPhone,Grid grid, List<EmpActual> empActualList) {
        this.planName = planName;
        this.kaoQinName = kaoQinName;
        this.startTime = startTime;
        this.endTime = endTime;
        this.degreeCompletion = degreeCompletion;
        this.gridName = gridName;
        this.depName = depName;
        this.userName = userName;
        this.userPhone = userPhone;
        this.grid = grid;
        this.empActualList = empActualList;
    }

    public BigDecimal getDegreeCompletionDecimal() {
        if (StringUtils.isNotEmpty(degreeCompletion)) {
            return new BigDecimal(getDegreeCompletion());
        }
        return BigDecimal.ZERO;
    }

    private static <T> String getString(T t, Function<? super T, ? extends String> classifier) {
        if (Objects.nonNull(t)) {
            return classifier.apply(t);
        } else {
            return "";
        }
    }

    public static Boolean getTimeBoolean() {
        //还是以美国纽约时区为例
        ZoneId zoneId = ZoneId.of("Asia/Shanghai");
        //获取当前时区当前时间
        LocalDateTime localDateTime = LocalDateTime.now();
        //设置ZonedDateTime对象
        ZonedDateTime zonedDateTime = localDateTime.atZone(zoneId);
        //获取时区计时规则
        ZoneRules rules = zoneId.getRules();
        //true表示处于夏令时，否则冬令时
        return rules.isDaylightSavings(zonedDateTime.toInstant());
    }
}
